<extend name="Index:base" />
<block name="title"><title>店铺等级</title></block>
<block name="style">
 <style>
.main,.panel-default>.panel-heading{
background:none;
}
body{
background:none;
}
.panel.panel-default,.panel .panel-body,.panel .panel-heading,.table-bordered {
	border:none;
}
.table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
	border:none;		
	padding:15px;	
	line-height:8px;
	height: 8px;
	border-top: 1px solid #d4d4d4;
	border-bottom: 1px solid #d4d4d4;
}
.name strong{
color:#000000;
font-size:15px;
font-weight:600;
}
.name {
	color:#20a8d8;
	font-size:12px;
}
.smallfont {
	color:#9c9c9c;
	font-size:12px;
}

.align-center{
	text-align:center; 
}
.title2{
text-align:center;
}
.table-bordered > tbody > tr .wd{
	text-align:left;	
}

.col-xs-2,.col-xs-4{
padding-right:0;
margin:10px 0;
}
.col-sm-3{
width:10%;
}
.col-sm-2{
width:8%;
}
.col-sm-1{
width:5%;
}
.col-sm-4{
width:18%;
}
.col-sm-1,.col-sm-2{
margin:16px 0;
}
.col-sm-3,.col-sm-4{
margin:10px 0;
}
.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4{
padding-right:0;
}
 </style>
</block>
	<!-- start: Header -->
<block name="body">

			<!-- end: Main Menu -->
						
		<!-- start: Content -->
		<div class="main ">
		
			<div class="row">
				<div class="col-lg-12">
					<h3 class="page-header"><i class="fa fa-life-bouy"></i>店铺等级管理</h3>
				</div>
			</div>

			<div class="row">		
				<div class="col-lg-12">
					<div class="panel panel-default">
						<div class="panel-heading">
							<h2><span class="break"></span><strong>店铺等级</strong></h2>&nbsp;&nbsp;&nbsp;
							<a class="btn btn-success" role="button" data-toggle="modal" href="#again" id="add_right">新增等级</i></a>
												
						</div>&nbsp;&nbsp;&nbsp;
						<ol class="breadcrumb" style="height:55px;background-color: #ffffff;">							
							<li><i class="fa fa-warning"></i><a href="#">操作提示：</a></li><br/>	
							<li><font style="font-size:8px;color:#888;"></font></li>							
						</ol>
						<div class="panel-body">

							<table class="table table-striped table-bordered bootstrap-datatable datatable">
							  <thead>
								  <tr>
									  
                                      <th>级别</th>
									  <th class="">等级名称</th>
									  <th class="title2">可发布商品数</th>
									  <th class="title2">可上传图片数</th>
									<!--   <th class="title2">可选模板套数</th> -->
									  <th class="title2">收费标准</th>
									  <th class="title2">操作</th>
								  </tr>
							  </thead>   
							  <tbody id="state">
								<foreach name="list" item="vo">
								<tr>
									
									<td>{$vo.sg_sort}</td>
									<td class="wd">
										{$vo.sg_name}
									</td>
									 <td class="align-center">{$vo.sg_goods_limit}</td>
									 <td class="align-center">{$vo.sg_album_limit}</td>
									<!--  <td class="align-center">{$vo.sg_template_number}</td> -->
									 <td class="align-center">{$vo.sg_price}</td>

									<td class="align-center">
										<a class="label label-primary" role="button" data-toggle="modal" href="#edit" data-id="{$vo.sg_id}" data-name="{$vo.sg_name}" data-goods="{$vo.sg_goods_limit}"  data-album="{$vo.sg_album_limit}" data-price="{$vo.sg_price}" data-sort="{$vo.sg_sort}" data-type="edit">编辑</i>
										</a>
										<if condition="$vo.sg_sort eq '0'">
										<a href="#" >												
										&nbsp;&nbsp;<span class="label label-danger" style="background-color: #999;">默认等级不能删除</span>
										</a>
										
										<else/>
										<a href="#" data-type="del" data-id="{$vo.sg_id}">
												
										&nbsp;&nbsp;<span class="label label-danger" >删除</span>
										</a>
										</if>											
									 </td>

								</tr>
								</foreach>
							  </tbody>
						  </table>  
							<ul class="pagination">
								{$page}
							 </ul>						  
						</div>
					</div>
				</div><!--/col-->
			
			</div><!--/row-->				
			
		<!-- end: Content -->
		<br><br><br>
		
	</div><!--/container-->
<!--添加新会员-->	
        <div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="again" class="modal fade add_right">
		
            <div class="modal-dialog public-top"  id="">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="title">添加等级</h4>
                    </div>
					<form action="{:U('Store/addSt')}" method="post" class="form-horizontal" id="action">
						<div class="modal-body">
							<label class=""><font style="color:red;">*</font>等级名称:</label>
							<div class="">
								<input type="text" id="sg_name" name="sg_name" value="" class="form-control placeholder-no-fix" placeholder="必填">
							</div></br>

							<label class=""><font style="color:red;">*</font>级别:</label>
							<div class="">
								<input type="text" id="sg_sort" name="sg_sort" value="1" class="form-control placeholder-no-fix" placeholder="不填默认为1">
							</div></br>
							
							<label class="">可发布商品数:</label>
							<div class="">
								<input type="text" id="goods_limit" name="sg_goods_limit" class="form-control placeholder-no-fix" placeholder="不填为无上限">
							</div></br>
							<label class="">可上传图片数:</label>
							<div class="">
								<input type="text" id="album_limit" name="sg_album_limit" class="form-control placeholder-no-fix" placeholder="不填为无上限">
							</div></br>
							
							<label class="">收费标准:</label>
							<div class="">								
				                <input type="text" id="sg_price" name="sg_price" class="form-control placeholder-no-fix" placeholder="不填为0">
				            </div></br>

						</div></br>
						<input type="hidden"  name="sg_id" id="sg_id" value="">
						<input type="hidden"  name="type" id="type" value="grade_add">
						<div class="modal-footer">
							<button data-dismiss="modal" class="btn btn-default" type="button">关闭</button>
							<button class="btn btn-primary mypost" type="sunmit">确认</button>
						</div>
					</form>	
              </div>
            </div>
        </div>		
</block>
<block name="script">
<script>
$("#add_right").click(function(){

	$(".add_right").attr('id','again');
	$("#action").attr('action',"{:U('Store/addSt')}");	
	$("#title").html('添加等级');
	$("#sg_name").val('');
	$("#goods_limit").val('');
	$("#album_limit").val('');
	$("#sg_price").val('');
	$("#sg_id").val('');
	$("#sg_sort").val('');	
	$("#type").val('grade_add');
});

$("#state tr td a").click(function(){

    var id = $(this).attr('data-id');
	var type = $(this).attr('data-type');
	var sg_name = $(this).attr('data-name');
	var goods_limit = $(this).attr('data-goods');
	var album_limit = $(this).attr('data-album');
	var sg_price = $(this).attr('data-price');
	var sg_sort = $(this).attr('data-sort');
	//alert(type);
	if (type=='edit'){			
		$(".add_right").attr('id',type);		
		$("#title").html('修改等级');
		$("#sg_name").val(sg_name);
		$("#goods_limit").val(goods_limit);
		$("#album_limit").val(album_limit);
		$("#sg_price").val(sg_price);
		$("#sg_sort").val(sg_sort);
		$("#sg_id").val(id);
		$("#type").val('grade_edit');
	}
	

	if (type=='del') {
		$.ajax({
			url:"{:U('Store/del')}",
			data:{id:id,table:2,str:'sg_id'},
			type:'post',
			dataType:'json',
			success:function (e) {			
			//alert(id);
				alert(e.info); 
				location.reload();				
			}
		});	
	}

});
</script>
</block>	









